package com.lagou.utils;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;

import java.sql.SQLException;

/**
 * @Author ZHAO Yudong
 * @Date 2020/11/6 14:23
 * @description：
 */
public class DruidUtils {

    private static DruidDataSource druidDataSource = new DruidDataSource();

    static {
        druidDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
        druidDataSource.setDbType("com.alibaba.druid.pool.DruidDataSource");
        druidDataSource.setUrl("jdbc:mysql://localhost:3306/bank?characterEncoding=utf8&serverTimezone=UTC");
        druidDataSource.setUsername("root");
        druidDataSource.setPassword("123456");
    }


    private DruidUtils() {
    }

    public static DruidDataSource getInstance() {
        return druidDataSource;
    }

    public static void main(String[] args) {
        try {
            DruidPooledConnection connection = DruidUtils.getInstance().getConnection();
            System.out.println(connection);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }

}
